package com.summer.oauth.center.service;

import com.summer.common.lock.Lock;
import com.summer.common.lock.LockKey;
import org.springframework.stereotype.Service;

@Service
public class PublicServiceImpl implements PublicService {

    /*@Autowired
    private DistributedLockHandler distributedLockHandler;*/

    /*@Override
    public void print(int val){
        System.out.println("获取锁之前");
        DistributedLock lock=new DistributedLock(this.getClass().getName()+".print","getLock");
        try {
            if (distributedLockHandler.tryLock(lock)){
                Thread.sleep(1000);
                System.out.println(System.currentTimeMillis());
                System.out.println("方法执行**********************************");

                distributedLockHandler.releaseLock(lock);
            } else {
                System.out.println("获取锁失败");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }*/

    @Override
    @Lock(timetOut = 1000*10)
    public void print(){
        try {
            Thread.sleep(1000);
            System.out.println(System.currentTimeMillis());
            System.out.println("方法执行**********************************");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
